<template>
	<el-tabs v-model="activeName" @tab-click="handleClick">
		<el-tab-pane label="红包列表" name="seventh">
			<!-- <div style="position: relative;display: inline-block;margin: 10px 0px;">
				<span>状态：</span>
				<el-select v-model="state" style="width:150px;margin-left: 10px;" @change="animeDat(state)">
					<el-option v-for="item in typeList" :key="item.value" :label="item.label" :value="item.value">
					</el-option>
				</el-select>&nbsp;&nbsp;&nbsp;
			</div> -->
			<div style="position: relative;display: inline-block;margin: 10px 0px;">
				<span>手机号：</span>
				<el-input style="width: 200px;" @keydown.enter.native="animeDat" placeholder="请输入手机号" v-model="phone">
				</el-input>&nbsp;&nbsp
			</div>
			<div style="position: relative;display: inline-block;margin: 10px 0px;">
				<span>昵称：</span>
				<el-input style="width: 200px;" @keydown.enter.native="animeDat" placeholder="请输入昵称" v-model="userName">
				</el-input>&nbsp;&nbsp
			</div>
			<div style="position: relative;display: inline-block;margin-right:2%;">
				<el-button style="margin-left:15px;" size="mini" type="primary" icon="document" @click="animeDat">查询
				</el-button>
				<el-button style="margin-left:15px;" size="mini" type="primary" icon="document" @click="cleans">重置
				</el-button>
			</div>
			<el-table v-loading="tableDataLoading" :data="tableData.records">
				<el-table-column fixed prop="redPacketId" label="编号" width="80">
				</el-table-column>
				<el-table-column fixed prop="userName" label="昵称" width="150">
					<template slot-scope="scope">
						<span style="color: #f56c6c;cursor: pointer;"
							@click="updataDetails(scope.row)">{{scope.row.userName ? scope.row.userName : '未绑定'}}</span>
					</template>
				</el-table-column>
				
				<el-table-column prop="phone" label="手机号">
				</el-table-column>
				<el-table-column prop="redPacketTitle" label="红包名称">
				</el-table-column>
				<el-table-column prop="expirationTime" label="使用类型">
					<template slot-scope="scope">
						<span v-if="scope.row.redPacketType==0">全部通用</span>
						<span v-else-if="scope.row.redPacketType==1">帮我送</span>
						<span v-else-if="scope.row.redPacketType==2">帮我取</span>
						<span v-else-if="scope.row.redPacketType==3">帮我买</span>
						<span v-else-if="scope.row.redPacketType==4">同城服务</span>
					</template>
				</el-table-column>
				<el-table-column prop="redPacketAmount" label="红包金额">
				</el-table-column>
				<el-table-column prop="minimumAmount" label="最低消费">
				</el-table-column>
				<el-table-column prop="expirationTime" label="过期时间">
				</el-table-column>
				<el-table-column prop="expirationTime" label="状态">
					<template slot-scope="scope">
						<span v-if="scope.row.deleteFlag==0">待使用</span>
						<span v-else-if="scope.row.deleteFlag==1">已使用</span>
						<span v-else-if="scope.row.deleteFlag==2">已失效</span>
					</template>
				</el-table-column>
			</el-table>
			<div style="text-align: center;margin-top: 10px;">
				<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
					:page-sizes="[10, 20, 30,50,100]" :page-size="limit" :current-page="page"
					layout="total,sizes, prev, pager, next" :total="tableData.total">
				</el-pagination>
			</div>
		</el-tab-pane>
	</el-tabs>
</template>

<script>
	export default {
		data() {
			return {
				limit: 10,
				page: 1,
				state: '',
				url: '',
				title: '',
				type: '',
				id: '',
				types: [{
						value: 'word',
						label: '文字'
					},
					{
						value: 'url',
						label: '链接'
					}
				],
				phone: '',
				userName:'',
				content: '',
				activeName: 'seventh',
				tableDataLoading: false,
				dialogFormVisible1: false,
				dialogFormVisible2: false,
				dialogFormVisible: false,
				tableData: [],
				typeList: [{
						value: '',
						label: '全部'
					},
					{
						value: 0,
						label: '待使用'
					},
					{
						value: 1,
						label: '已使用'
					},
					{
						value: 2,
						label: '已失效'
					}
				],
			}
		},
		methods: {
			// 详情跳转
			updataDetails(row) {
				this.$router.push({
					path: '/userDetail',
					query: {
						userId: row.userId
					}
				});
			},
			handleSizeChange(val) {
				this.limit = val;
				this.dataSelect()
			},
			handleCurrentChange(val) {
				this.page = val;
				this.dataSelect()
			},
			handleClick(tab, event) {

				if (tab._props.label == '红包列表') {
					this.page = 1
					this.limit = 10
					this.state = 8
					this.dataSelect()
				}
			},
			// 获取数据列表
			dataSelect() {
				this.tableDataLoading = true
				this.$http({
					url: this.$http.adornUrl('adminevaluate/selectRedPacket'),
					method: 'get',
					params: this.$http.adornParams({
						'page': this.page,
						'limit': this.limit,
						'userName': this.userName,
						'phone': this.phone
					})
				}).then(({
					data
				}) => {
					this.tableDataLoading = false
					let returnData = data.data;
					this.tableData = returnData
				})
			},
			animeDat() {
				this.page = 1
				this.dataSelect()
			},
			cleans() {
				this.page = 1
				this.phone = ''
				this.userName = ''
				this.dataSelect()
			}
		},
		mounted() {
			this.dataSelect()
		}
	};
</script>

<style>

</style>
